<!-- WEB CONTENT -->
<div id="container_content">
<div id="ad_main_name">
    <h2>Sell Your Ride</h2>
</div><br/>

<?php
//Paypal payment form - currently deactivated
//echo "<pre>" . print_r($data->error, true) . "</pre>";

// show only if this is a new advertise and if payments enabled
if($_GET['p'] !== 'adv_edit' && $data->require_payments) { // 1PC941932S349562R - valid tx ID for testing

    if(!isset($_GET['tx'])) {
        echo '<div id="paypal_holder">
        <p>
            The posting of new advertises costs $1 per advertise. Please click on the button to be securely
            redirected to Paypal and complete the payment. After the payment is successfully completed you will
            be redirected here and be able to finalize the advertise.
        </p>
        <div id="paypal_image">
            <form action="https://www.paypal.com/cgi-bin/webscr" method="POST" target="_top">
                <input type="hidden" name="cmd" value="_s-xclick">
                <input type="hidden" name="hosted_button_id" value="GW6LG6LDNYYES">
                <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
                <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
            </form>
        </div>
    </div>';
    } else {
        echo '<div id="paypal_holder">
                <p>Thank you for your payment. Your transaction has been completed, and a receipt for
                your purchase has been emailed to you. You may log into your account at
                <a href="https://www.paypal.com/" target="_blank">www.paypal.com</a> to view details of this
                transaction.<br/><br/>You can now proceed with posting the advertise.
            </p></div>';
    }
}
?>

<form method="POST" action="<?php echo ($data->adv_id ? '?p=adv_edit&adv_id='.$data->adv_id : '?p=adv_add');?>" enctype="multipart/form-data">
    <input type="hidden" name="seller_id" value="<?php echo $_SESSION['user_data']['user_id']; ?>"/>
    <input type="hidden" name="payment_tx_id" value="<?php echo $tx;?>">
    <div id="vehicle_state">
    <h2>Vehicle Details</h2>

    <div class="sell_your_raid_inputs_holder">
        <ul>
            <li> <div class="sell_your_ride_input">
                    <h3>Vehicle Detail*</h3>
                    <label for="vehicle_state"></label>
                    <select name="vehicle_state" id="vehicle_state">
                        <option value="">-- select --</option>
                        <?php
                        foreach ($data->lists['vehicle_states'] as $v) {
                            if($v == $data->vehicle_state) {
                                echo "<option value='".$v."' selected>${v}</option>";
                            } else {
                                echo "<option value='".$v."'>${v}</option>";
                            }
                        }
                        ?>
                    </select>
                </div>
            </li>

            <li> <div class="sell_your_ride_input">
                    <h3>Year</h3>
                    <select name="year" id="year">
                        <option value="">-- select --</option>
                        <?php
                        $current_year = date("Y");
                        for($i=$current_year; $i>=1940; $i--) {
                            if($i == $data->year) {
                                echo "<option value='".$i."' selected>${i}</option>";
                            } else {
                                echo "<option value='".$i."'>${i}</option>";
                            }
                        }
                        ?>
                    </select>

                </div>
            </li>


            <li> <div class="sell_your_ride_input">
                    <h3>Car Type</h3>
                    <select name="car_type" id="car_type">
                        <option value="">-- select --</option>
                        <?php
                        foreach ($data->lists['car_types'] as $v) {
                            if($v == $data->car_type) {
                                echo "<option value='".$v."' selected>${v}</option>";
                            } else {
                                echo "<option value='".$v."'>${v}</option>";
                            }
                        }
                        ?>
                    </select>
                </div>
            </li>

            <li> <div class="sell_your_ride_input">
                    <h3>Make</h3>
                    <select name="make" id="make" onchange="get_model(this.value)">
                        <option value="">-- select --</option>
                        <?php
                        foreach ($data->lists['makes'] as $v) {
                            if($v == $data->make) {
                                echo "<option value='".$v."' selected>${v}</option>";
                            } else {
                                echo "<option value='".$v."'>${v}</option>";
                            }
                        }
                        ?>
                    </select>

                </div>
            </li>
            <li> <div class="sell_your_ride_input">
                    <h3>Model</h3>
                    <select name="model" id="model">
                        <option value="">-- select --</option>
                    </select>

                </div>
            </li>

        </ul>

    </div>


    <div id="car_features_holder">
        <h2>Features</h2>
        <ul>
            <li>

                <div class="car_features">
                    <h3>Price(Naira)*</h3>
                    <label for="price"></label> <input type="text" name="price" id="price" value="<?php echo $data->price; ?>" />
                </div>


            </li>

            <li>

                <div class="car_features">
                    <h3>KMs*</h3>
                    <label for="kms"></label> <input type="text" name="kms" id="kms" value="<?php echo $data->kms; ?>" />
                </div>


            </li>



            <li> <div class="sell_your_ride_input">
                    <h3>Color*</h3>
                    <select name="color" id="color">
                        <option value="">-- select --</option>
                        <?php
                        foreach ($data->lists['colors'] as $v) {
                            if($v == $data->color) {
                                echo "<option value='".$v."' selected>${v}</option>";
                            } else {
                                echo "<option value='".$v."'>${v}</option>";
                            }
                        }
                        ?>
                    </select>

                </div>
            </li>
        </ul>


    </div>


    <div class="sell_your_raid_inputs_holder" id="extra_feautres_margin">
        <h2>Extra Features</h2>
        <ul>
            <li> <div class="sell_your_ride_input">
                    <h3>Fuel Type</h3>
                    <select name="fuel_type" id="fuel_type">
                        <option value="">-- select --</option>
                        <option value="Petrol" <?php echo ($data->fuel_type == 'Petrol' ? 'selected' : '');?>>Petrol</option>
                        <option value="Gas LPG" <?php echo ($data->fuel_type == 'Gas LPG' ? 'selected' : '');?>>Gas LPG</option>
                        <option value="Electric" <?php echo ($data->fuel_type == 'Electric' ? 'selected' : '');?>>Electric</option>
                        <option value="Hydrogen" <?php echo ($data->fuel_type == 'Hydrogen' ? 'selected' : '');?>>Hydrogen</option>
                        <option value="Diesel" <?php echo ($data->fuel_type == 'Diesel' ? 'selected' : '');?>>Diesel</option>
                        <option value="Natural Gas" <?php echo ($data->fuel_type == 'Natural Gas' ? 'selected' : '');?>>Natural Gas</option>
                        <option value="Hybrid (Petrol / Electric)" <?php echo ($data->fuel_type == 'Hybrid (Petrol / Electric)' ? 'selected' : '');?>>Hybrid (Petrol / Electric)</option>
                    </select>
                </div>
            </li>

            <li> <div class="sell_your_ride_input">
                    <h3>Gearbox</h3>
                    <select name="gearbox" id="gearbox">
                        <option value="">-- select --</option>
                        <option value="Semiautomatic" <?php echo ($data->gearbox == 'Semiautomatic' ? 'selected' : '');?>>Semiautomatic</option>
                        <option value="Automatic Transmission" <?php echo ($data->gearbox == 'Automatic Transmission' ? 'selected' : '');?>>Automatic Transmission</option>
                        <option value="Manual Gearbox" <?php echo ($data->gearbox == 'Manual Gearbox' ? 'selected' : '');?>>Manual Gearbox</option>
                    </select>

                </div>
            </li>


            <li> <div class="sell_your_ride_input">
                    <h3>Doors</h3>
                    <select name="doors" id="doors">
                        <option value="">-- select --</option>
                        <option value="3 doors" <?php echo ($data->doors == '3 doors' ? 'selected' : '');?>>3 doors</option>
                        <option value="5 doors" <?php echo ($data->doors == '5 doors' ? 'selected' : '');?>>5 doors</option>
                    </select>
                </div>
            </li>


        </ul>

    </div>


    <div id="sell_your_car_description">
        <h2>Description</h2>
        <label for="description"></label>
        <textarea name="description" id="description"><?php echo ($data->description ? $data->description : '');?></textarea>



    </div>




    <div id="car_contact_info_holder">
        <h2>Contact Info</h2>
        <ul>
            <li>

                <div class="car_features">
                    <h3>Name*</h3>
                    <label for="contact_name"></label>
                    <input type="text" name="contact_name" id="contact_name" value="<?php echo $data->contact_name; ?>" />
                </div>


            </li>

            <li>

                <div class="car_features">
                    <h3>Mobile*</h3>
                    <label for="contact_phone"></label>
                    <input type="text" name="contact_phone" id="contact_phone" value="<?php echo $data->contact_phone; ?>" />
                </div>


            </li>

            <li>

                <div class="car_features">
                    <h3>Email*</h3>
                    <label for="contact_email"></label>
                    <input type="text" name="contact_email" id="contact_email" value="<?php echo $data->contact_email; ?>" />
                </div>


            </li>

            <li>

                <div class="car_features">
                    <h3>City</h3>
                    <label for="contact_city"></label>
                    <input type="text" name="contact_city" id="contact_city" value="<?php echo $data->contact_city; ?>" />
                </div>


            </li>




        </ul>


    </div>

    <div id="car_sale_gallery">
        <h2>Gallery</h2>

        <div class="upload_file_gallery1">
            <?php
            if(!empty($data->picture1)) {
                echo "<img src='".$data->picture1."' />";
            }
            ?>
            <div class="delete"></div>
            <label for="picture1"></label> <input type="file" name="picture1" id="picture1" />
        </div>

        <div class="mini_picutres_holder">


            <div class="upload_file_gallery">
                <?php
                if(!empty($data->picture2)) {
                    echo "<img src='".$data->picture2."' />";
                }
                ?>
                <div class="delete"></div>
                <label for="picture2"></label> <input type="file" name="picture2" id="picture2" />
            </div>


            <div class="upload_file_gallery">
                <?php
                if(!empty($data->picture3)) {
                    echo "<img src='".$data->picture3."' />";
                }
                ?>
                <div class="delete"></div>
                <label for="picture3"></label> <input type="file" name="picture3" id="picture3" />
            </div>

            <div class="upload_file_gallery">
                <?php
                if(!empty($data->picture4)) {
                    echo "<img src='".$data->picture4."' />";
                }
                ?>
                <div class="delete"></div>
                <label for="picture4"></label> <input type="file" name="picture4" id="picture4" />
            </div>


            <div class="upload_file_gallery">
                <?php
                if(!empty($data->picture5)) {
                    echo "<img src='".$data->picture5."' />";
                }
                ?>
                <div class="delete"></div>
                <label for="picture5"></label> <input type="file" name="picture5" id="picture5" />
            </div>


            <div class="upload_file_gallery">
                <?php
                if(!empty($data->picture6)) {
                    echo "<img src='".$data->picture6."' />";
                }
                ?>
                <div class="delete"></div>
                <label for="picture6"></label> <input type="file" name="picture6" id="picture6" />
            </div>


            <div class="upload_file_gallery">
                <?php
                if(!empty($data->picture7)) {
                    echo "<img src='".$data->picture7."' />";
                }
                ?>
                <div class="delete"></div>
                <label for="picture7"></label> <input type="file" name="picture7" id="picture7" />
            </div>



            <div class="upload_file_gallery">
                <?php
                if(!empty($data->picture8)) {
                    echo "<img src='".$data->picture8."' />";
                }
                ?>
                <div class="delete"></div>
                <label for="picture8"></label> <input type="file" name="picture8" id="picture8" />
            </div>


            <div class="upload_file_gallery">
                <?php
                if(!empty($data->picture9)) {
                    echo "<img src='".$data->picture9."' />";
                }
                ?>
                <div class="delete"></div>
                <label for="picture9"></label> <input type="file" name="picture9" id="picture9" />
            </div>




        </div>
    </div>

    </div>
    <div id="submit_advartise">
    <ul>
                            <li><label for="tac"></label><input type="checkbox" name="tac" id="tac" value="1"></li>
                            <li>
                                <p>
                                    I agree to the <span>Advertiser Terms & Conditions</span>
                                </p>
                            </li>
                        </ul>
    <input type="image" src="img/submit_advartise.png" value="Submit Advertise" name="submit"/>
    </div>
</form>
</div>
<script>
    //update model dynamically from database
    function get_model($make, $selected_model) {
        if ($make=="") {
            document.getElementById("model").innerHTML = "";
            return;
        }

        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("model").innerHTML = xmlhttp.responseText;
            }
        };

        xmlhttp.open("GET","?p=get_models&make=" + $make + "&selected_model=" + $selected_model, true);
        xmlhttp.send();
    }

    <?php
     if(isset($data->model)) {
        echo "get_model('".urlencode($data->make)."', '".urlencode($data->model)."');";
     }
    ?>
</script>